package com.fuluwa.interfaces.pay.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fuluwa.application.pay.biz.PayBiz;
import com.fuluwa.application.pay.bo.AlipayBo;
import com.fuluwa.application.pay.bo.TenpayBo;
import com.fuluwa.infra.web.AbstractDomainController;
import com.fuluwa.infra.web.Result;
import com.fuluwa.interfaces.pay.web.vo.PayVo;

/**
 * 支付Controller,TODO 需要实现一个工厂，用来区分不同的支付方式
 * 
 * @author leasenli
 * 
 */
@Controller
@RequestMapping(value = "/pay")
public class PayController extends AbstractDomainController {

	@Autowired
//	@Qualifier("tenpayBiz")
	private PayBiz<TenpayBo> tenpayBiz;

	@Autowired
//	@Qualifier("alipayBiz")
	private PayBiz<AlipayBo> alipayBiz;

	@RequestMapping(value = "/tenpay", method = RequestMethod.GET)
	@ResponseBody
	public Result tenpay(@RequestBody PayVo payVo) {
		tenpayBiz.genPayUrl(convertVo2TenpayBo(payVo));
		return getSuccessResult();
	}

	@RequestMapping(value = "/alipay", method = RequestMethod.GET)
	@ResponseBody
	public Result alipay(@RequestBody PayVo payVo) {
		alipayBiz.genPayUrl(convertVo2AlipayBo(payVo));
		return getSuccessResult();
	}

	private TenpayBo convertVo2TenpayBo(PayVo payVo) {
		return new TenpayBo();
	}

	private AlipayBo convertVo2AlipayBo(PayVo payVo) {
		return new AlipayBo();
	}
}
